import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';

import '../../res/colors.dart';
import 'device_repair_record_fragment.dart';
import 'device_repair_submit_fragment.dart';

class DeviceRepairSubmitPage extends BaseStatefulMvvmWidget {
  final String? id;
  final String? content;

  DeviceRepairSubmitPage({this.id, this.content});

  @override
  State<StatefulWidget> createState() => _DeviceRepairSubmitState();
}

class _DeviceRepairSubmitState
    extends BaseMvvmState<CommonViewModel, DeviceRepairSubmitPage> {
  List<String> get titles => <String>["维保待执行", "维保维修记录"];

  @override
  Widget buildLoadingContentView() {
    return DefaultTabController(
        length: titles.length,
        child: Column(
          children: [
            TabBar(
                unselectedLabelColor: Colors.black,
                labelColor: Colours.app_main,
                indicatorColor: Colours.app_main,
                indicatorSize: TabBarIndicatorSize.label,
                tabs: titles
                    .map((e) => Tab(
                          text: e,
                        ))
                    .toList()).addToContainer(color: Colors.white),
            TabBarView(children: [
              DeviceRepairSubmitFragment(id: widget.id,content: widget.content,),
              DeviceRepairRecordFragment(id: widget.id,content: widget.content,),
            ]).setWeight(1)
          ],
        ));
  }


  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return Scaffold(
      appBar: AppBar(
        title: Text('设备维保执行'),
      ),
      body: loadingContentWidget,
    );
  }

  @override
  CommonViewModel createViewModel() {
    return CommonViewModel(context);
  }

  @override
  void onRetryClick() {}
}
